<template>
  <div class="app-container">

    <h2 style="text-align: center;">发布新课程</h2>
    <!-- 步骤导航 -->
    <el-steps :active="active" finish-status="success" simple style="margin-top: 20px">
      <el-step title="编辑课程基本信息" icon="el-icon-edit"/>
      <el-step title="编辑课程大纲" icon="el-icon-upload"/>
      <el-step title="课程发布" icon="el-icon-picture"/>
    </el-steps>

    <!-- step1：编写课程基本信息 -->
    <info v-if="active === 0" />

    <!-- step2：创建课程大纲 -->
    <chapter v-if="active === 1"/>

    <!-- step3：发布课程 active = 3 发布成功 -->
    <publish v-if="active === 2 || active === 3" />

  </div>
</template>

<script>
// 将子组件嵌入到父组件中：
// 步骤1：引入子组件、步骤2：注册子组件、步骤3：使用子组件
import Info from '@/views/course/components/Info'
import Chapter from '@/views/course/components/Chapter'
import Publish from '@/views/course/components/Publish'

export default {

  components: {
    Info, Chapter, Publish
  },

  data() {
    return {
      active: 0,
      courseId: ''
    }
  },
  created() {
    // 获取路由id
    if (this.$route.params.id) {
      this.courseId = this.$route.params.id
    }

    if (this.$route.name === 'CourseInfoEdit') {
      this.active = 0
    }

    if (this.$route.name === 'CourseChapterEdit') {
      this.active = 1
    }
  }
}
</script>
